#ifndef _GRAPHMATRIX_H_
#define _GRAPHMATRIX_H_
#include <stdio.h>
#include <stdlib.h>

typedef char VexType;
typedef int AdjType;
typedef int VertexIndex; // index for a specific vertex in the graph matrix

struct Vertex
{
    VexType v;
    int index;
    int visit;
};

typedef struct Vertex * PVertex;

struct GraphMatrix
{
    int n;
    struct Vertex *vexs;
    AdjType ** arcs;
};

typedef struct GraphMatrix *PGraphMatrix;

PGraphMatrix createGraph(int n, AdjType ** ajt);

int isNullGraph(PGraphMatrix graph);

PVertex firstVertex(PGraphMatrix graph);
PVertex nextVertex(PGraphMatrix graph, PVertex vi);
PVertex findVertex(PGraphMatrix graph, VexType value);
int deleteVertex(PGraphMatrix graph, PVertex vi);

int hasVertex(PGraphMatrix graph, PVertex vi);

int deleteEdge(PGraphMatrix graph, PVertex vi, PVertex vj);
int addEdge(PGraphMatrix grpah, PVertex vi, PVertex vj);
int findEdge(PGraphMatrix graph, PVertex vi, PVertex vj);

PVertex firstAdjacent(PGraphMatrix graph, PVertex vi);
PVertex nextAdjacent(PGraphMatrix graph, PVertex vi, PVertex vj);

void dftGraph(PGraphMatrix graph);
void dfsGraph(PGraphMatrix graph, PVertex vi);
void bftGraph(PGraphMatrix graph);
void bfsGraph(PGraphMatrix graph, PVertex vi);

int print(PGraphMatrix graph);
int printVertex(PGraphMatrix graph, PVertex vi);

int destroyGraph(PGraphMatrix *graph);
#endif
